/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans",
    "Helvetica Neue", sans-serif;
    color: #333;
    background-color: #f5f5f5;
}

/* 工作流搭建器容器 */
.workflow-builder {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* 头部样式 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background-color: #fff;
    border-bottom: 1px solid #e0e0e0;
}

.header-left {
    display: flex;
    align-items: center;
}

.logo {
    width: 2rem;
    height: 2rem;
    background-color: #f9ca24;
    color: white;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    margin-right: 0.5rem;
}

.header h1 {
    font-size: 1.125rem;
    font-weight: 500;
}

.header-right {
    display: flex;
    gap: 0.5rem;
}

/* 按钮样式 */
.btn {
    display: flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn svg {
    margin-right: 0.25rem;
}

.btn-primary {
    background-color: #000;
    color: #fff;
    border: none;
}

.btn-primary:hover {
    background-color: #333;
}

.btn-secondary {
    background-color: #fff;
    color: #333;
    border: 1px solid #e0e0e0;
}

.btn-secondary:hover {
    background-color: #f5f5f5;
}

/* 主体内容 */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 左侧节点面板 */
.node-panel {
    width: 12rem;
    background-color: #fff;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
}

.node-category {
    padding: 0.75rem;
    border-bottom: 1px solid #e0e0e0;
}

.node-category h3 {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #555;
}

.search-box {
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 0.375rem 0.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

.node-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.node-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.node-item:hover {
    background-color: #f5f5f5;
}

.node-icon {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    margin-bottom: 0.25rem;
}

.node-item span {
    font-size: 0.75rem;
}

.start-icon {
    background-color: #e8f0fe;
    color: #4285f4;
}

.input-icon {
    background-color: #e6f7ff;
    color: #1890ff;
}

.transform-icon {
    background-color: #e6ffed;
    color: #52c41a;
}

.code-icon {
    background-color: #fffbe6;
    color: #faad14;
}

.condition-icon {
    background-color: #fff2e8;
    color: #fa541c;
}

.loop-icon {
    background-color: #f9f0ff;
    color: #722ed1;
}

.database-icon {
    background-color: #f0f5ff;
    color: #2f54eb;
}

.api-icon {
    background-color: #e6fffb;
    color: #13c2c2;
}

.output-icon {
    background-color: #f0f2f5;
    color: #595959;
}

.timer-icon {
    background-color: #fff0f6;
    color: #eb2f96;
}

.notification-icon {
    background-color: #fcf4dc;
    color: #d48806;
}

.function-icon {
    background-color: #f9f0ff;
    color: #722ed1;
}

/* 中间画布 */
.canvas-container {
    flex: 1;
    position: relative;
    overflow: auto;
    background-color: #fafafa;
}

.canvas {
    position: relative;
    width: 3000px;
    height: 3000px;
    transform-origin: 0 0;
    transition: transform 0.1s ease;
}

.canvas-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: 20px 20px;
    background-image: linear-gradient(to right, #e0e0e0 1px, transparent 1px),
    linear-gradient(to bottom, #e0e0e0 1px, transparent 1px);
    z-index: 0;
}

/* 节点样式 */
.workflow-node {
    position: absolute;
    min-width: 120px;
    padding: 0.75rem;
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 0.25rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    cursor: move;
    z-index: 10;
}

.workflow-node-header {
    display: flex;
    align-items: center;
}

.workflow-node-icon {
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    margin-right: 0.5rem;
}

.workflow-node-title {
    font-size: 0.875rem;
    font-weight: 500;
}

/* 右侧属性面板 */
.property-panel {
    width: 18rem;
    background-color: #fff;
    border-left: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
}

.property-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
}

.property-header h3 {
    font-size: 0.875rem;
    font-weight: 500;
}

.close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
}

.property-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.no-selection {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    font-size: 0.875rem;
}

.node-info {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

.node-info-icon {
    width: 2rem;
    height: 2rem;
    background-color: #e6f7ff;
    color: #1890ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.5rem;
    font-weight: 500;
}

.node-info-title {
    font-size: 0.875rem;
    font-weight: 500;
}

.node-info-id {
    font-size: 0.75rem;
    color: #999;
}

.property-tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 1rem;
}

.tab-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
}

.tab-btn.active {
    color: #1890ff;
    border-bottom: 2px solid #1890ff;
    font-weight: 500;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.form-control {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

.code-editor-container {
    display: none;
}

.code-editor {
    font-family: monospace;
    min-height: 10rem;
    margin-top: 0.5rem;
}

.checkbox-group {
    display: flex;
    align-items: center;
}

.checkbox-group input {
    margin-right: 0.5rem;
}

.checkbox-group label {
    margin-bottom: 0;
    cursor: pointer;
}

/* 底部工具栏 */
.toolbar {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background-color: #fff;
    border-top: 1px solid #e0e0e0;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.tool-btn {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    color: #666;
}

.tool-btn:hover {
    background-color: #f5f5f5;
}

.zoom-level {
    font-size: 0.75rem;
    color: #666;
    margin-left: 0.5rem;
}

/* jsPlumb 连接点样式 */
.endpoint {
    z-index: 20;
}

.jtk-connector {
    z-index: 5;
}

.jtk-endpoint {
    z-index: 15;
}

.jtk-overlay {
    z-index: 15;
}

/* 选中节点的样式 */
.workflow-node.selected {
    border: 2px solid #1890ff;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

/* 拖拽预览样式 */
.drag-preview {
    pointer-events: none;
    opacity: 0.7;
    z-index: 1000;
}

/* 缩放控制 */
.canvas {
    transform-origin: 0 0;
    transition: transform 0.1s ease;
}

/* 添加缩略图样式 */
#minimap-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 150px;
    border: 1px solid #ccc;
    background-color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
    overflow: hidden;
}

#minimap-canvas {
    width: 100%;
    height: 100%;
}

/* 移除视口样式，因为不再需要拖拽 */
#minimap-viewport {
    display: none;
}

/* 添加拖拽手柄样式 */
#minimap-viewport::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    background-color: #1890ff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

/* 添加颜色选择器样式 */
.color-picker {
    padding: 0;
    height: 36px;
}

/* 添加连接线标签样式 */
.jtk-overlay.connection-label {
    background-color: white;
    padding: 2px 5px;
    border-radius: 3px;
    border: 1px solid #e0e0e0;
    font-size: 12px;
}

/* 添加节点样式设置相关样式 */
.style-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.style-option {
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid #e0e0e0;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s;
}

.style-option:hover {
    transform: scale(1.05);
}

.style-option.selected {
    border: 2px solid #1890ff;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

/* 预览模式样式 */
.preview-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.preview-container {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 90%;
    height: 90%;
    display: flex;
    flex-direction: column;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
}

.preview-content {
    flex: 1;
    padding: 1rem;
    overflow: auto;
    display: flex;
    flex-direction: column;
}

.preview-footer {
    display: flex;
    justify-content: flex-end;
    padding: 1rem;
    border-top: 1px solid #e0e0e0;
}

.close-icon {
    cursor: pointer;
}

.preview-tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 1rem;
}

.preview-tab {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
}

.preview-tab.active {
    color: #1890ff;
    border-bottom: 2px solid #1890ff;
    font-weight: 500;
}

.preview-tab-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.preview-canvas-container {
    flex: 2;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: auto;
    margin-right: 1rem;
    position: relative;
    min-height: 600px;
}

/* Add styles for the interactive preview canvas */
.interactive-preview-canvas {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: auto;
    min-height: 600px;
    background-color: #fafafa;
}

/* Style for preview grid */
.preview-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
}

.preview-info {
    flex: 1;
    overflow: auto;
}

.preview-list {
    margin-top: 0.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto;
}

.preview-list-item {
    padding: 0.5rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
}

.preview-list-item:last-child {
    border-bottom: none;
}

.preview-node-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    margin-right: 0.5rem;
}

.json-viewer {
    background-color: #f5f5f5;
    padding: 1rem;
    border-radius: 4px;
    font-family: monospace;
    white-space: pre-wrap;
    overflow: auto;
    height: 100%;
    margin: 0;
}

/* 保存对话框样式 */
.save-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.save-container {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 500px;
    padding: 1.5rem;
}

.save-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.save-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.save-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

/* 不同的节点样式预设 */
.node-style-default {
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.node-style-modern {
    background-color: white;
    border: none;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.node-style-flat {
    background-color: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 0;
    box-shadow: none;
}

.node-style-rounded {
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Update for preview node styles */
.interactive-preview-canvas .workflow-node {
    cursor: move;
    z-index: 10;
    position: absolute;
}

a {
    text-decoration: none;
    color: #000;
}

.btn-primary a {
    color: #fff;
}

/* Hide the original static canvas since we're using an interactive one */
#preview-canvas {
    display: none;
}
